﻿Imports MeoTom.Core.BLL
Imports Microsoft.ApplicationBlocks.Data

Namespace DAL
    Public Class PublicUploadProvider
        Inherits DataAccess
        Private ReadOnly _objUtil As New Utilities.Common

        Public Sub New()
            strConn = Configs.ConnectionStringUp
        End Sub

        Public Function GetUpload(ByVal objPublicUpload As PublicUploads) As DataSet
            Dim param(3) As SqlClient.SqlParameter
            param(0) = New SqlClient.SqlParameter("@Status", SqlDbType.Int, 4)
            param(0).Value = _objUtil.ConvertBoolToInt(objPublicUpload.Status)
            param(1) = New SqlClient.SqlParameter("@TotalRecord", SqlDbType.Int, 4)
            param(1).Value = objPublicUpload.TotalRecord
            param(2) = New SqlClient.SqlParameter("@OrderBy", SqlDbType.VarChar, 4)
            param(2).Value = objPublicUpload.OrderBy

            Return SqlHelper.ExecuteDataset(strConn, CommandType.StoredProcedure, "GetUpload", param)
        End Function

        Public Sub UpdateUpload(ByVal objPublicUpload As PublicUploads)
            Dim param(1) As SqlClient.SqlParameter
            param(0) = New SqlClient.SqlParameter("@UploadID", SqlDbType.VarChar, 150)
            param(0).Value = objPublicUpload.UploadID

            SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "UpdateUpload", param)
        End Sub

        Public Sub DeleteUpload(ByVal objPublicUpload As PublicUploads)
            Dim param(1) As SqlClient.SqlParameter
            param(0) = New SqlClient.SqlParameter("@UploadID", SqlDbType.VarChar, 150)
            param(0).Value = objPublicUpload.UploadID

            SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "DeleteUpload", param)
        End Sub

        Public Function GetByID(ByVal objPublicUpload As PublicUploads) As SqlClient.SqlDataReader
            Dim param(1) As SqlClient.SqlParameter
            param(0) = New SqlClient.SqlParameter("@UploadID", SqlDbType.VarChar, 150)
            param(0).Value = objPublicUpload.UploadID

            Return SqlHelper.ExecuteReader(strConn, CommandType.StoredProcedure, "GetByID", param)
        End Function
    End Class
End Namespace